﻿using CinemaMaestro.DataLayer.Contracts.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CinemaMaestro.ViewModels
{
    public class ReservationViewModel
    {
        public int Id { get; set; }
        public int TicketNr { get; set; }
        public int DiscountTicketNr { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string TelephoneNr { get; set; }
        public string ReservedSeats { get; set; }

        public virtual ScreeningViewModel Screening { get; set; }

        public static implicit operator ReservationViewModel(Reservation reservation)
        {
            return new ReservationViewModel
            {
                Id = reservation.Id,
                TicketNr = reservation.TicketNr,
                DiscountTicketNr = reservation.DiscountTicketNr,
                Name = reservation.Name,
                Email = reservation.Email,
                TelephoneNr = reservation.TelephoneNr,
                ReservedSeats = reservation.ReservatedSeats,
                Screening = reservation.Screening              
            };
        }

        public static implicit operator Reservation(ReservationViewModel reservationVM)
        {
            return new Reservation
            {
                Id = reservationVM.Id,
                TicketNr = reservationVM.TicketNr,
                DiscountTicketNr = reservationVM.DiscountTicketNr,
                Name = reservationVM.Name,
                Email = reservationVM.Email,
                TelephoneNr = reservationVM.TelephoneNr,
                ReservatedSeats = reservationVM.ReservedSeats,
                Screening = reservationVM.Screening      
            };
        }

        public override string ToString()
        {
            return Name;
        }

    }
}
